﻿@using EasyMvcBlog.DTO
@model ArticleDTO
<div class="box">
    <div class="bar">
        <span class="barTitle"><a href="@Url.Action("Index","Article",Model.Id)">@Model.Title</a>
        </span><span class="barRight">love </span>
    </div>
    <div class="boxCon" style="min-height: 600px;">
        @Html.Raw(Model.Content)
    </div>
    <div class="boxBottom">
        <span class="color999">Category:</span> <span class="category"><a href="#" class="aNor colorblue">@Model.Category.CategoryName</a>
        </span><span class="color999">Tags:</span> <span class="tags">
            @foreach (Tag tag in Model.Tags)
              {
                <a href="#"><span class="tagPic"></span><span class="tagName">@tag.TagName</span>
                </a>
              }
        </span>
    </div>
</div>
@if (Model.DenyComment)
{
   @: Comment is Closed
   <div style="clear:both;height:20px;"></div>
}
else
{
    using (Html.BeginForm("AddComment", "Home", FormMethod.Post, new { id = "commentForm" }))
    {
        <a name="commentMark"></a>
        <div class="box commentBox">
            @Html.Hidden("articleId", Model.Id)
            <div class="commentUserInfo">
                <p>
                    <label for="userName">
                        Nick Name</label>
                    <span class="require">*</span>
                    @Html.TextBox("userName", null, new { style = "padding-left:70px;width:185px;" })
                </p>
                <p class="commentUserMail">
                    <label for="userMail">
                        Email</label>
                    <span class="require">*</span>
                    @Html.TextBox("userMail", null, new { style = "padding-left:40px;width:215px;" })
                </p>
                <p style="left: 542px;" class="commentWebSite">
                    <label for="userWebSite">
                        Website</label>
                    @Html.TextBox("userWebSite")
                </p>
            </div>
            <div class="commentContent">
                <label for="comment">
                </label>
                @Html.TextArea("comment")
            </div>
            <div class="commentBottomBar">
                <p class="noticeMe">
                    @Html.CheckBox("noticeMe", true)
                    <label for="noticeMe">
                        When got reply,notice me via email</label>
                </p>
                <p style="float: right;">
                    <input type="button" value="Submit" class="submit" id="commentSubmit" />
                </p>
            </div>
            <div style="clear: both;">
            </div>
        </div>
    }
}
@{int index = 1;}
@foreach (CommentDTO comment in ViewBag.ArticleComment as List<CommentDTO>)
{
    <div class="box">
        <div class="bar">
            @if (string.IsNullOrEmpty(comment.Website))
            {
                <span class="barTitle">#@index @comment.UserName:</span>
            }
            else
            { 
                <span class="barTitle commentUser">#@index <a href="@comment.Website">@comment.UserName:</a></span>                
            }
            <span class="barRight">@comment.CreatedTime</span>
        </div>
        <div class="boxCon" style="min-height: 50px;">
            @Html.Raw(comment.CommentContent)
        </div>
        <div class="boxBottom">
            @if (User.Identity.IsAuthenticated)
            {
                     <span class="deleteReply" CommentId="@comment.Id">&nbsp;|&nbsp;Delete Reply</span>
            }
            <span class="replyComment">Reply</span>
        </div>
        <div style="clear: both;">
        </div>
    </div>
    
    index++;
}
